package com.voiceqsologger.controller;

import com.voiceqsologger.entity.QsoLog;
import com.voiceqsologger.service.CommEntityExtractorParser;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 文本解析预览接口
 */
@RestController
@RequestMapping("/api/parse")
@RequiredArgsConstructor
public class ParseController {

    private final CommEntityExtractorParser parser;

    @PostMapping("/qso")
    public QsoLog parse(@RequestBody Map<String, String> body) {
        String text = body.getOrDefault("text", "");
        String my = body.get("myCallsign");
        return parser.parse(text, my);
    }
}


